<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>add</title>
    <script th:src="@{/js/axios.js}"></script>
    <script th:src="@{/js/vue.js}"></script>
    <link rel="stylesheet" th:href="@{/js/el/theme-chalk/index.css}">
    <script th:src="@{/js/el/index.js}"></script>
</head>
<body>
<div id="app">
    <el-container style="height:1000px;" >
        <el-header style="height:7%;padding: 0px;">
            <div th:include="~{common/head-fore::headFore}">

            </div>
        </el-header>
        <el-container>
            <el-main>
                <div style="width:50%;text-align: center">
                    <el-input v-model="user.name">
                        <template slot="prepend">登录账号</template>
                    </el-input>
                    <br>
                    <el-input v-model="user.password">
                        <template slot="prepend">登录密码</template>
                    </el-input>
                    <br>
                    <el-input v-model="nextPwd">
                        <template slot="prepend">确认密码</template>
                    </el-input>
                    <br>
                    <button @click="addUser()">
                        添加用户
                    </button>
                    <button @click="goIndex()">
                        返回首页
                    </button>
                </div>
            </el-main>
        </el-container>
    </el-container>
</div>

</body>
<script>
    new Vue({
        el:"#app",
        data(){
            return{
                user:{},
                nextPwd:""
            }
        },
        methods:{
            addUser(){
                var that = this
                if(this.user.password  == this.nextPwd){
                    axios.post("/api/public/user/add",this.user).then(
                        function (resp) {
                            that.goIndex()
                        }
                    )
                }
            },
            goIndex(){
                window.location.href="/api/public/goIndex"
            }
        },
        mounted(){

        }
    })
</script>
</html>